﻿package plugin.qhtips
{
    import cmd.*;
    import com.core.*;
    import flash.events.*;
    import flash.geom.*;
    import manager.*;
    import pluginfw.nio.*;
    import uiresource.bag.*;
    import view.appDrag.*;

    public class QhTipsCtrl extends QhTipsUI implements IRoot
    {
        private var itemid:int;
        private var zbid:int;

        public function QhTipsCtrl()
        {
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            AppDragMgr.RegisterModule(this);
            quedingBtn.addEventListener(MouseEvent.CLICK, this.qhclick);
            quxiaoBtn.addEventListener(MouseEvent.CLICK, this.onclose);
            closebtn.addEventListener(MouseEvent.CLICK, this.onclose);
            return;
        }// end function

        public function openRefresh(param1:Object) : void
        {
            this.init(param1);
            return;
        }// end function

        public function init(param1:Object) : void
        {
            qianghua.text = "+" + param1.bufferparam;
            this.itemid = int(param1.itemid);
            item.data = null;
            return;
        }// end function

        protected function onclose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function close() : void
        {
            ModelProxy.change("plugin", "close", "qhtips");
            item.data = null;
            this.itemid = -1;
            this.zbid = -1;
            return;
        }// end function

        protected function qhclick(event:MouseEvent) : void
        {
            var _loc_2:Output = null;
            if (item.data)
            {
                _loc_2 = new Output();
                _loc_2.writeVarInt(this.itemid, false);
                _loc_2.writeVarInt(this.zbid, false);
                ModelProxy.change("data", "isdjqh", true);
                PluginManager.instance.sendToBufferServer("qianghua", CMDQiangHua.ITEM_QH, _loc_2);
            }
            this.close();
            return;
        }// end function

        public function DragOver(param1:Object, param2:Point, param3:String) : void
        {
            var _loc_4:Point = null;
            if (param3 == "bag")
            {
                _loc_4 = item.globalToLocal(param2);
                if (_loc_4.y > 0 && _loc_4.x > 0 && _loc_4.x < 60 && _loc_4.y < 60)
                {
                    if (param1[4].itemtype == 1)
                    {
                        item.data = param1[4];
                        this.zbid = param1[0];
                    }
                }
            }
            return;
        }// end function

    }
}
